﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbCurve : OdDbEntity
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbCurve(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbCurve_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbCurve obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbCurve()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbCurve(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbCurve cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbCurve_cast(OdRxObject.getCPtr(pObj));
			OdDbCurve result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbCurve)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbCurve)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbCurve)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbCurve_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbCurve_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbCurve_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdDbCurve createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbCurve_createObject();
			OdDbCurve result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbCurve)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbCurve)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbCurve)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isClosed()
		{
			bool result = TD_DbPINVOKE.OdDbCurve_isClosed(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isPeriodic()
		{
			bool result = TD_DbPINVOKE.OdDbCurve_isPeriodic(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getStartParam(out double startParam)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getStartParam(this.swigCPtr, out startParam);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getEndParam(out double endParam)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getEndParam(this.swigCPtr, out endParam);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getStartPoint(OdGePoint3d startPoint)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getStartPoint(this.swigCPtr, OdGePoint3d.getCPtr(startPoint));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getEndPoint(OdGePoint3d endPoint)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getEndPoint(this.swigCPtr, OdGePoint3d.getCPtr(endPoint));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getPointAtParam(double param, OdGePoint3d pointOnCurve)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getPointAtParam(this.swigCPtr, param, OdGePoint3d.getCPtr(pointOnCurve));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getParamAtPoint(OdGePoint3d pointOnCurve, out double param)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getParamAtPoint(this.swigCPtr, OdGePoint3d.getCPtr(pointOnCurve), out param);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getDistAtParam(double param, out double dist)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getDistAtParam(this.swigCPtr, param, out dist);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getParamAtDist(double dist, out double param)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getParamAtDist(this.swigCPtr, dist, out param);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getDistAtPoint(OdGePoint3d pointOnCurve, out double dist)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getDistAtPoint(this.swigCPtr, OdGePoint3d.getCPtr(pointOnCurve), out dist);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getPointAtDist(double dist, OdGePoint3d pointOnCurve)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getPointAtDist(this.swigCPtr, dist, OdGePoint3d.getCPtr(pointOnCurve));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getFirstDeriv(double param, OdGeVector3d firstDeriv)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getFirstDeriv__SWIG_0(this.swigCPtr, param, OdGeVector3d.getCPtr(firstDeriv));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getFirstDeriv(OdGePoint3d pointOnCurve, OdGeVector3d firstDeriv)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getFirstDeriv__SWIG_1(this.swigCPtr, OdGePoint3d.getCPtr(pointOnCurve), OdGeVector3d.getCPtr(firstDeriv));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getSecondDeriv(double param, OdGeVector3d secondDeriv)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getSecondDeriv__SWIG_0(this.swigCPtr, param, OdGeVector3d.getCPtr(secondDeriv));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getSecondDeriv(OdGePoint3d pointOnCurve, OdGeVector3d secondDeriv)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getSecondDeriv__SWIG_1(this.swigCPtr, OdGePoint3d.getCPtr(pointOnCurve), OdGeVector3d.getCPtr(secondDeriv));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getClosestPointTo(OdGePoint3d givenPoint, OdGePoint3d pointOnCurve, bool extend)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getClosestPointTo__SWIG_0(this.swigCPtr, OdGePoint3d.getCPtr(givenPoint), OdGePoint3d.getCPtr(pointOnCurve), extend);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getClosestPointTo(OdGePoint3d givenPoint, OdGePoint3d pointOnCurve)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getClosestPointTo__SWIG_1(this.swigCPtr, OdGePoint3d.getCPtr(givenPoint), OdGePoint3d.getCPtr(pointOnCurve));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getClosestPointTo(OdGePoint3d givenPoint, OdGeVector3d normal, OdGePoint3d pointOnCurve, bool extend)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getClosestPointTo__SWIG_2(this.swigCPtr, OdGePoint3d.getCPtr(givenPoint), OdGeVector3d.getCPtr(normal), OdGePoint3d.getCPtr(pointOnCurve), extend);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getClosestPointTo(OdGePoint3d givenPoint, OdGeVector3d normal, OdGePoint3d pointOnCurve)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getClosestPointTo__SWIG_3(this.swigCPtr, OdGePoint3d.getCPtr(givenPoint), OdGeVector3d.getCPtr(normal), OdGePoint3d.getCPtr(pointOnCurve));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getSpline(out OdDbSpline spline)
		{
			IntPtr zero = IntPtr.Zero;
			OdResult result;
			try
			{
				OdResult odResult = (OdResult)TD_DbPINVOKE.OdDbCurve_getSpline(this.swigCPtr, out zero);
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odResult;
			}
			finally
			{
				spline = (OdDbSpline)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
			return result;
		}

		public virtual OdResult extend(double param)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_extend__SWIG_0(this.swigCPtr, param);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult extend(bool extendStart, OdGePoint3d toPoint)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_extend__SWIG_1(this.swigCPtr, extendStart, OdGePoint3d.getCPtr(toPoint));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getArea(out double area)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getArea(this.swigCPtr, out area);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getOrthoProjectedCurve(OdGePlane projPlane, out OdDbCurve pProjCurve)
		{
			IntPtr zero = IntPtr.Zero;
			OdResult result;
			try
			{
				OdResult odResult = (OdResult)TD_DbPINVOKE.OdDbCurve_getOrthoProjectedCurve(this.swigCPtr, OdGePlane.getCPtr(projPlane), out zero);
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odResult;
			}
			finally
			{
				pProjCurve = (OdDbCurve)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
			return result;
		}

		public virtual OdResult getProjectedCurve(OdGePlane projPlane, OdGeVector3d projDirection, out OdDbCurve pProjCurve)
		{
			IntPtr zero = IntPtr.Zero;
			OdResult result;
			try
			{
				OdResult odResult = (OdResult)TD_DbPINVOKE.OdDbCurve_getProjectedCurve(this.swigCPtr, OdGePlane.getCPtr(projPlane), OdGeVector3d.getCPtr(projDirection), out zero);
				if (TD_DbPINVOKE.SWIGPendingException.Pending)
				{
					throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
				}
				result = odResult;
			}
			finally
			{
				pProjCurve = (OdDbCurve)Teigha.Core.Helpers.odrxCreateObjectInternal(zero, true);
			}
			return result;
		}

		public virtual OdResult getOffsetCurves(double offsetDistance, OdRxObjectPtrArray offsetCurves)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getOffsetCurves(this.swigCPtr, offsetDistance, OdRxObjectPtrArray.getCPtr(offsetCurves));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getOffsetCurvesGivenPlaneNormal(OdGeVector3d normal, double offsetDistance, OdRxObjectPtrArray offsetCurves)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getOffsetCurvesGivenPlaneNormal(this.swigCPtr, OdGeVector3d.getCPtr(normal), offsetDistance, OdRxObjectPtrArray.getCPtr(offsetCurves));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getSplitCurves(OdGeDoubleArray arg0, OdRxObjectPtrArray curveSegments)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getSplitCurves__SWIG_0(this.swigCPtr, OdGeDoubleArray.getCPtr(arg0), OdRxObjectPtrArray.getCPtr(curveSegments));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getSplitCurves(OdGePoint3dArray points, OdRxObjectPtrArray curveSegments)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getSplitCurves__SWIG_1(this.swigCPtr, OdGePoint3dArray.getCPtr(points), OdRxObjectPtrArray.getCPtr(curveSegments));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult reverseCurve()
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_reverseCurve(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getOdGeCurve(OdGeCurve3d pGeCurve, OdGeTol tol)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getOdGeCurve__SWIG_0(this.swigCPtr, pGeCurve, OdGeTol.getCPtr(tol));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult getOdGeCurve(OdGeCurve3d pGeCurve)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_getOdGeCurve__SWIG_1(this.swigCPtr, pGeCurve);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdResult createFromOdGeCurve(OdGeCurve3d geCurve, SWIGTYPE_p_p_OdDbCurve pDbCurve, OdGeVector3d normal, OdGeTol tol)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_createFromOdGeCurve__SWIG_0(OdGeCurve3d.getCPtr(geCurve), SWIGTYPE_p_p_OdDbCurve.getCPtr(pDbCurve), OdGeVector3d.getCPtr(normal), OdGeTol.getCPtr(tol));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdResult createFromOdGeCurve(OdGeCurve3d geCurve, SWIGTYPE_p_p_OdDbCurve pDbCurve, OdGeVector3d normal)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_createFromOdGeCurve__SWIG_1(OdGeCurve3d.getCPtr(geCurve), SWIGTYPE_p_p_OdDbCurve.getCPtr(pDbCurve), OdGeVector3d.getCPtr(normal));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdResult createFromOdGeCurve(OdGeCurve3d geCurve, SWIGTYPE_p_p_OdDbCurve pDbCurve)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_createFromOdGeCurve__SWIG_2(OdGeCurve3d.getCPtr(geCurve), SWIGTYPE_p_p_OdDbCurve.getCPtr(pDbCurve));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult setFromOdGeCurve(OdGeCurve3d geCurve, OdGeVector3d normal, OdGeTol tol)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_setFromOdGeCurve__SWIG_0(this.swigCPtr, OdGeCurve3d.getCPtr(geCurve), OdGeVector3d.getCPtr(normal), OdGeTol.getCPtr(tol));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult setFromOdGeCurve(OdGeCurve3d geCurve, OdGeVector3d normal)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_setFromOdGeCurve__SWIG_1(this.swigCPtr, OdGeCurve3d.getCPtr(geCurve), OdGeVector3d.getCPtr(normal));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult setFromOdGeCurve(OdGeCurve3d geCurve)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbCurve_setFromOdGeCurve__SWIG_2(this.swigCPtr, OdGeCurve3d.getCPtr(geCurve));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
